<template>
<div>   
   <city-header>city-header</city-header>
   <city-search :cities ="allcities">city-search</city-search>
   <city-list :hotlist="hotCities" :allcities ="allcities" :letter = "letter">city-list</city-list>
   <city-alphabet :allcities ="allcities" @change2="handleLetterChange">city-alphabet</city-alphabet>
</div>
</template>
<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
	  return{
          hotCities:[],
          allcities:{},
          letter:''
	  }
  },
  methods:{
    getCityInfo () {
       axios.get('/api/city.json').then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res){     
  		res = res.data
  	    if(res.ret && res.data){   
  		  this.hotCities = res.data.hotCities
  		  this.allcities = res.data.cities
  		}
    },
    handleLetterChange(letter){
       this.letter = letter
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>
<style>
</style>
